package com.gt.wxpay.cashier.payChannel.callback;

import com.gt.wxpay.cashier.payChannel.callback.handler.WxPayCallBackNotifyService;
import com.gt.wxpay.cashier.payChannel.callback.vo.WxNotifyVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author @Mapper
 * @since 2017/9/24
 */
@RestController
@RequestMapping("/wxpay/notify")
public class WxPayNotifyController {
    private static Logger logger = LoggerFactory.getLogger(WxPayNotifyController.class);
    @Autowired
    private WxPayCallBackNotifyService wxPayCallBackNotifyService;

    /**
     * 支付结果：回调接口通知
     *
     * @return
     */
    @RequestMapping("/pay")
    public WxNotifyVo pay(HttpServletRequest request) throws Exception {
        logger.info("微信支付回调通知------->");
        return wxPayCallBackNotifyService.dealPayResultV3(request);
    }

    /**
     * 退款结果通知
     *
     * @return
     */
    @RequestMapping("/refund")
    public WxNotifyVo refund(HttpServletRequest request) throws Exception {
        logger.info("微信退款回调通知------->");
        return wxPayCallBackNotifyService.dealRefundResultV3(request);
    }

}
